package com.practice.springboot_01_zwj.service.impl;

import com.practice.springboot_01_zwj.entity.ShangJi;
import com.practice.springboot_01_zwj.mapper.ShangJiMapper;
import com.practice.springboot_01_zwj.service.ShangJiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional

public class ShangJiServiceImpl implements ShangJiService {
    @Autowired
    private ShangJiMapper shangJiMapper;

    @Override
    public List<ShangJi> getMetricsByType(String type) {
        switch (type.toUpperCase()) {
            case "CHU_BEI_PER":
                return shangJiMapper.selectByChuBeiPer();
            case "ZHUAN_HUAN_PER":
                return shangJiMapper.selectByZhuanHuanPer();
            case "QIAN_ZHI_PER":
                return shangJiMapper.selectByQianZhiPer();
            case "LOU_BU_PER":
                return shangJiMapper.selectByLouBuPer();
            case "FU_PAN_PER":
                return shangJiMapper.selectByFuPanPer();
            case "ZERO_ZB_QX_PER":
                return shangJiMapper.selectByZeroZbQxPer();
            case "PROJECT_EXPAND":
                return shangJiMapper.selectByProjectExpand();
            case "ZB_DOUBLE_AMOUNT":
                return shangJiMapper.selectByZbDoubleAmount();
            case "ZB_DOUBLE_COUNT":
                return shangJiMapper.selectByZbDoubleCount();
            default:
                throw new IllegalArgumentException("Invalid type: " + type);
        }
    }
}
